package com.sbtr.business.classify.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbtr.business.classify.dto.AlgorithmInfoDto;
import com.sbtr.business.classify.entity.AlgorithmInfo;
import com.sbtr.business.classify.mapper.AlgorithmMapper;
import com.sbtr.business.classify.service.AlgorithmInfoService;
import com.sbtr.common.PageDto;
import com.sbtr.util.BeanCopyUtils;
import com.sbtr.util.PageDtoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author laimh
* @version 创建时间：2020年3月9日 上午10:20:45
* @Description 类描述
*/
@Transactional
@Service
public class AlgorithmInfoServiceImpl extends ServiceImpl<AlgorithmMapper, AlgorithmInfo> implements AlgorithmInfoService {
	@Autowired
	AlgorithmMapper algorithmInfoMapper;

	@Override
	public PageDto<AlgorithmInfo> pageList(AlgorithmInfoDto algorithmInfoDto) {

		IPage<AlgorithmInfo> page = new Page<>();
		page.setSize(algorithmInfoDto.getPageSize());
		page.setCurrent(algorithmInfoDto.getPage());
		page = algorithmInfoMapper.selectPages(page, BeanUtil.beanToMap(algorithmInfoDto));
		PageDto<AlgorithmInfo> r = PageDtoUtils.getPageDtoByIPage(page, AlgorithmInfo.class);

		return r;
	}
	public List<AlgorithmInfoDto> getAlgorithmInfo(){
		List<AlgorithmInfo> algorithmInfo = baseMapper.getAlgorithmInfo();
		return BeanCopyUtils.copyProperties(algorithmInfo, AlgorithmInfoDto.class);
	}



	public List<AlgorithmInfoDto> getAlgorithmInfoByProjectType(String projectType){
		List<AlgorithmInfo> algorithmInfo = baseMapper.getAlgorithmInfoByProjectType(projectType);
		return BeanCopyUtils.copyProperties(algorithmInfo, AlgorithmInfoDto.class);
	}


	public List<String> getProjectType(){
		return baseMapper.getProjectType();
	}

	public List<String> getAlgorithmName(){
		return baseMapper.getAlgorithmName();
	}


}
